'''
Queries to fetch data
Created on Jul 20, 2014
@author: ANAND
'''
import sqlite3

db_file = "eb2day.db"

# symbol_id text, my_symbol text, my_series text, cur_open real, cur_high real, cur_low real, cur_close real, cur_pvt real, cur_volume integer, 
#    pre_open real, pre_high real, pre_low real, pre_close real, pre_pvt real, eod_trend integer, strong_trend integer, olh_trend integer, per_change real

def allbuy():
    conn = sqlite3.connect(db_file)
    c = conn.cursor()
    c.execute("SELECT my_symbol, cur_close, pre_close, per_change, cur_volume, strong_trend, olh_trend FROM stocks WHERE eod_trend=1")
    res = c.fetchall()
    conn.close()
    return(res)

def allsell():
    conn = sqlite3.connect(db_file)
    c = conn.cursor()
    c.execute("SELECT my_symbol, cur_close, pre_close, per_change, cur_volume, strong_trend, olh_trend FROM stocks WHERE eod_trend=2")
    res = c.fetchall()
    conn.close()
    return(res)

def allstocks():
    conn = sqlite3.connect(db_file)
    c = conn.cursor()
    c.execute("SELECT my_symbol, my_series, cur_close, my_change, per_change, cur_open, cur_high, cur_low, cur_pvt, cur_volume, pre_high, pre_low, pre_close, eod_trend, strong_trend, olh_trend FROM stocks")
    res = c.fetchall()
    conn.close()
    return(res)
